package com.example.administrator.damaiwang.fragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.damaiwang.R;
import com.example.administrator.damaiwang.bean.LBean;

import java.util.List;

import it.sephiroth.android.library.picasso.Picasso;

/**
 * A simple {@link Fragment} subclass.
 */
public class DetailsFragment extends Fragment {
private List<LBean> lBeen;
private int position ;
    private String BASR_URL1 = "http://pimg.damai.cn/perform/project/";
    public DetailsFragment(int position) {
        // Required empty public constructor
        this.position=position;
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_details, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        final ImageView iv= (ImageView) view.findViewById(R.id.iv_show);
        final TextView tv_name= (TextView) view.findViewById(R.id.tv_name);
        final TextView tv_time= (TextView) view.findViewById(R.id.tv_time);
        final TextView tv_address= (TextView) view.findViewById(R.id.tv_address);
        final TextView tv_price= (TextView) view.findViewById(R.id.tv_price);
        Fragment_all.send(new Fragment_all.sendMessage() {
            @Override
            public void send(List<LBean> lBeens) {
                lBeen=lBeens;
                tv_name.setText(lBeen.get(position).getN());
                tv_address.setText("场馆: "+lBeen.get(position).getVenName());
                tv_price.setText(lBeen.get(position).getPriceName());
                tv_time.setText("时间: "+lBeen.get(position).getT());
                String i = String.valueOf(lBeen.get(position).getI());
                String imageUrl = BASR_URL1 + i.substring(0,4) +"/"+i+"_n.jpg";
                Picasso.with(getActivity()).load(imageUrl).into(iv);
            }
        });

    }
}
